import random
import sys
import time

print("+------------------------------------+")
print("|                                    |")
print("|        花有重开日  人无再少年          |")
print("|                                    |")
print("|        欢迎来到 人生重开模拟器         |")
print("|                                    |")
print("+------------------------------------+")

# 设置初始属性
while True:
    print("请设定初始属性(可用总点数20)")
    face = int(input("请输入颜值(1-10): "))
    strong = int(input("请输入颜值(1-10): "))
    iq = int(input("请输入智力(1-10): "))
    home = int(input("请输入家境体质(1-10): "))

    if face < 1 or face > 10:
        print("颜值属性设置无效,请重新设置!")
        continue
    if strong < 1 or strong > 10:
        print("体质属性设置无效,请重新设置!")
        continue
    if iq < 1 or iq > 10:
        print("智力属性设置无效,请重新设置!")
        continue
    if home < 1 or home > 10:
        print("家境属性设置无效,请重新设置!")
        continue
    if face + strong + iq + home > 20:
        print("属性值总和超过20,设置无效,请重新设置!")
        continue
    print("初始属性设置成功!")
    print(f"颜值: {face}, 体质: {strong}, 智力: {iq}, 家境: {home}")
    break

# 设置性别

point = int(random.randint(0, 6))
if point % 2 == 0:
    gender = "boy"
    print("你是一个男孩")
else:
    gender = "girl"
    print("你是一个女孩")

# 设置出生点
if home == 10:
    print("你出生在大城市,你的父母是高管政要")
    face += 1
    strong += 1
    iq += 2
elif 8 < home < 9:
    if point == 1:
        print("你出生在大城市,你的父母是企业家")
        face += 1
        strong += 1
        iq += 1
    elif point == 2:
        print("你出生在大城市,你的父母是大学教授")
        iq += 2
    elif point == 3:
        print("你出生在大城市,你的父母是白领")
elif 5 < home < 8:
    if point == 1:
        print("你出生在小城镇,你的父母是普通打工人")
    elif point == 2:
        print("你出生在二线城市,你的父母是小学教师")
    else:
        print("你出生在二线城市,你的父母是医生")
else:
    if point == 1:
        print("你出生在农村,你的父母是农民")
    elif point == 2:
        print("你出生在穷乡僻壤,你父母无业游民")
    else:
        print("你出生在猪圈,你的父母把你生下来就抛弃了")

# 针对每一岁,生成人生经历

for age in range(1,11):
    info = ""
    point = random.randint(1, 3)
    if home > 7 and iq > 6:
        info += "你深受父母长辈的喜爱"
        face += 1
        iq += 1
    elif gender == "girl" and home < 3 and strong < 3:
        info += "你的父母重男轻女,没钱治病"
        face -= 1
        strong -= 1
        iq += 1
    elif gender == 'boy' and strong > 7 and iq < 6:
        info += "你的经常跟别的同学起冲突,打架"
        face -= 1
        strong += 1
        iq -= 1
        home -= 1
    elif strong < 3 and home < 5:
        info += "你体弱多病,家中没钱治疗,最终病情积累致死亡"
        sys.exit(0)
    elif strong > 6 and face > 7:
        info += "你深受周围同学的青睐,许多同学都愿意和你交朋友"
        face += 1
        strong += 1
        iq += 1
    elif iq < 4 and face < 4:
        info += "你做事蠢笨,受到其他同学的欺负"
        face -= 1
        strong -= 1
        home -= 1
    elif home < 5 and strong > 6 and iq < 6:
        info += "你家境贫困,经常自己解决伙食"
        face -= 1
        strong -= 1
        iq += 1
    elif home < 5 and iq > 8:
        info += "你聪明机智,找到许多赚钱的小妙招"
        home += 1
        iq += 1
        strong += 1
        face += 1
    else:
        info += "你茁壮成长,无难无灾"
        if point == 1:
            face += 1
        elif point == 2:
            strong += 1
        else:
            iq += 1
    print(f"-------------第{age}年---------------")
    print(info)
    print(f"颜值: {face}, 体质: {strong}, 智力: {iq}, 家境: {home}")
    time.sleep(2)
